package com.yun.zf.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yun.zf.common.admin.dto.sys.SubStationDto;
import com.yun.zf.common.app.domain.ZfSubwayStation;
import com.yun.zf.system.mapper.ZfSubwayStationMapper;
import com.yun.zf.system.service.ZfSubwayStationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 地铁站表 服务实现类
 * </p>
 *
 * @author cj
 * @since 2021-01-29
 */
@Service
public class ZfSubwayStationServiceImpl extends ServiceImpl<ZfSubwayStationMapper, ZfSubwayStation> implements ZfSubwayStationService {

    @Override
    public List<SubStationDto> subwayStations(Long subwayId) {
            return baseMapper.getStations(subwayId);
    }

    @Override
    public Boolean addStations(List<ZfSubwayStation> stations) {
        return this.saveBatch(stations);
    }

    @Override
    public int addStation(ZfSubwayStation station) {
        return baseMapper.insert(station);
    }

    /**
     * 获取地铁线下地铁站点Id
     * @param subwayId
     * @return
     */
    @Override
    public List<String> getStationPois(Long subwayId) {
        QueryWrapper<ZfSubwayStation> subwayStationQueryWrapper = new QueryWrapper<>();
        subwayStationQueryWrapper.lambda().eq(ZfSubwayStation::getSubwayId,subwayId);
        List<ZfSubwayStation> stations = baseMapper.selectList(subwayStationQueryWrapper);
        //从list集合中，取出字段poi的列表
        List<String> pois = stations.stream().map(p -> p.getPoiId()).collect(Collectors.toList());
        return pois;
    }
}
